﻿using MediatR;
using SheepStorage.API.Application.Command.RoleManCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.RoleManHandler
{
	/// <summary>
	/// 角色分配菜单
	/// </summary>
	public class RoleToMenuHandler : IRequestHandler<RoleToMenuCommand, Results<int>>
	{

		IRolesService service;

		public RoleToMenuHandler(IRolesService service)
		{
			this.service = service;
		}




		public async Task<Results<int>> Handle(RoleToMenuCommand request, CancellationToken cancellationToken)
		{
			 var res= await service.AddMenuToRole(request.RoleId, request.MenuIdList);
			return Results<int>.DataResult(res);
		}
	}
}
